package com.walle.concurrenttest.juc.lock;

import java.util.concurrent.locks.ReentrantLock;

/**
 * @author zhangjiapeng
 * @Package com.walle.concurrenttest.juc.lock
 * @Description: ${todo}
 * @date 2019/3/6 14:58
 */
public class FairB implements Runnable {

    private ReentrantLock lock;

    public FairB(ReentrantLock lock) {
        this.lock = lock;
    }

    @Override
    public void run() {
        while (true){
            lock.lock();
            try {
                System.out.println("FairB get Lock");
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }finally {
                lock.unlock();
            }
        }
    }
}
